<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Recent Timesheets</title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span>
            <span class="menuButton"><g:link class="list" action="list">Timesheet List</g:link></span>
	    <span class="menuButton"><g:link class="list" action="listCompleted" controller="workset" params="[displayName:params.displayName]" >Spot Check</g:link></span>
	</div>
        <div class="body">
	    <h1>Recent Timesheets</h1>
	    <div><g:form name="changeDisplayName" controller="timesheet" action="listRecent">for user name: <g:textField name="displayName" value="${params.displayName}" /> with <strong>${params.unpaidPieces}</strong> unpaid completed Pieces to date</g:form>
	    </div>
	    <div><g:form name="markAllPaid" controller="timesheet" action="listRecent"><g:submitButton name="paySheets" value="Mark All Timesheets Paid" /><g:hiddenField name="displayName" value="${params.displayName}" /></g:form>
	    </div>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                        
                                <g:sortableColumn property="id" title="Id" />
                        
                                <g:sortableColumn property="dateCreated" title="Date Created" />
                        
                                <th>Nickname</th>
                            
                                <g:sortableColumn property="period" title="Period" />

				<g:sortableColumn property="totalCompleted" title="Total Completed" />

				<g:sortableColumn property="totalSeen" title="Total Seen" />

				<g:sortableColumn property="paid" title="Paid" />

				<g:sortableColumn property="lastUpdated" title="Last Updated" />
                        
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${timesheetList}" status="i" var="sheet">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                            <td><g:link action="show" id="${sheet.id}">${sheet.id?.encodeAsHTML()}</g:link></td>
                            <td>${sheet.dateCreated?.encodeAsHTML()}</td>
                            <td>${sheet.nickname?.encodeAsHTML()}</td>
                            <td>${sheet.period?.encodeAsHTML()}</td>
			    <td>${sheet.totalCompleted?.encodeAsHTML()}</td>
			    <td>${sheet.totalSeen?.encodeAsHTML()}</td>
			    <td>${sheet.paid?.encodeAsHTML()}</td>
			    <td>${sheet.lastUpdated?.encodeAsHTML()}</td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${params.timesheetForNicknameCount}" />
            </div>
        </div>
    </body>
</html>

